package com.baor.controller;


import com.baor.service.ExceptionManagerService;
import com.baor.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/exceptionManager")
public class ExceptionManagerController {
    @Autowired
    private ExceptionManagerService exceptionManagerService;

    @RequestMapping(value ="/getList",produces = "application/json")
    public R getExceptionManager(@RequestBody Map<String,Object> params){
        R r = this.exceptionManagerService.getList(params);
        return  R.ok(r);
    }
    @RequestMapping("/getEquipment")
    public R getExceptionManagerInfo(@RequestBody Map<String,Object> params){
        R r = this.exceptionManagerService.getCode(params);
        return  R.ok(r);
    }
    @RequestMapping("/insert")
    public R insert(@RequestBody Map<String,Object> params){
        R r = this.exceptionManagerService.insert(params);
        return  R.ok(r);
    }
    @RequestMapping("/getCompanyList")
    public R getCompanyList(@RequestBody Map<String,Object> params){
        R r = this.exceptionManagerService.getCompanyList(params);
        return  R.ok(r);
    }

    /**
     * 获取设备安装记录
     * equipment_id 设备id
     * installer_id 安装人id
     * install_time 安装时间
     * @param params
     * @return
     */
    @RequestMapping("/installList")
    public R getInstallList(@RequestBody Map<String,Object> params){
        R r = this.exceptionManagerService.getInstallList(params);
        return  R.ok(r);
    }
    @RequestMapping("/getInfo/{id}")
    public R getInfo(@PathVariable("id") Integer id){
        R r = this.exceptionManagerService.getInfo(id);
        return  R.ok(r);
    }
    @RequestMapping("/update")
    public R update(@RequestBody Map<String,Object> params){
        R r = this.exceptionManagerService.update(params);
        return  R.ok(r);
    }

    //TODO 设备日志
    @RequestMapping("/getLog")
    public R getLog(@RequestBody Map<String,Object> params){
        R r = this.exceptionManagerService.getLog(params);
        return  R.ok(r);
    }
}
